package com.mikelouis.test.scala.proginscala.chapter19

class Publication(val title: String)

class Book(title: String) extends Publication(title)

object Library {
  val books: Set[Book] =
    Set(
      new Book("Programming in Scala"),
      new Book("Walden")
    )

  /**
   * Me:
   * 函数的参数类型: 需要是逆变的
   * 函数的返回结果类型: 需要是协变的
   * @param info
   */
  def printBookList(info: Book => AnyRef) {
    for (book <- books) println(info(book))
  }
}

object Customer extends Application {
  def getTitle(p: Publication): String = p.title

  Library.printBookList(getTitle)
}
